home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / examples / scheme / cell < prev    next >
Encoding:
Text File  |  1989-02-17  |  563 b   |  24 lines

  1. ;;; -*-Scheme-*-
  2.  
  3. (define (make-cell)
  4.   (call-with-current-continuation
  5.     (lambda (return-from-make-cell)
  6.       (letrec ((state
  7.          (call-with-current-continuation
  8.            (lambda (return-new-state)
  9.              (return-from-make-cell
  10.                (lambda (op)
  11.              (case op
  12.                ((set)
  13.                 (lambda (value)
  14.                   (call-with-current-continuation
  15.                 (lambda (return-from-access)
  16.                   (return-new-state
  17.                     (list value return-from-access))))))
  18.                ((get) (car state)))))))))
  19.     ((cadr state) 'done)))))
  20.  
  21. (define c (make-cell))
  22. (print ((c 'set) 99))
  23. (print (c 'get))
  24.